home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
2099
/
2099.xpi
/
chrome
/
javascript.js
< prev
next >
Wrap
Text File
|
2006-04-04
|
5KB
|
190 lines
function Repaginator()
{
}
Repaginator.prototype.enabled = false;
Repaginator.prototype.pagecounter = 0;
Repaginator.prototype.prevPage = '';
// Get last item in a container
Repaginator.prototype.getLast = function(container)
{
var item = container.iterateNext();
var temp = item;
while(temp != null)
{
temp = container.iterateNext();
if(temp != null)
{
item = temp;
}
}
return item;
};
Repaginator.prototype.blast = function(win)
{
try
{
var xresult = win.document
.evaluate(
this.query,
win.document,null,0,null);
var node = this.getLast(xresult);
if(node != null)
{
win.document.body.setAttribute('repagination','isOn');
var iframe = win.document.createElement('iframe');
this.iframe = iframe;
iframe.style.display='none';
iframe.setAttribute('src',node.href);
repagination.RegisterRepaginator(this);
iframe.addEventListener('load',function(event)
{
repagination.GetRepaginator(this).loadNext(this);
},true);
win.document.body.setAttribute('repagination','isOn');
win.document.body.appendChild(iframe);
}
else
{
win.document.body.setAttribute('repagination','isOff');
}
}
catch(ex)
{
win.document.body.setAttribute('repagination','isOff');
}
};
Repaginator.prototype.beforeNum = Repaginator.prototype.afterNum =
Repaginator.prototype.numStr = '';
Repaginator.prototype.isSelect = true;
Repaginator.prototype.loadNextThunk = function()
{
myRepaginator.loadNext(myRepaginator.iframe);
};
Repaginator.prototype.increment = function()
{
this.query = this.query.replace(new RegExp(this.numberToIncrement, 'g'), Number(this.numberToIncrement) + 1);
this.numberToIncrement++;
};
/// Append all children of source to target
Repaginator.prototype.AppendChildren = function(source, target)
{
//alert(source);
//alert(source.firstChild);
for (var child = source.firstChild; child != null; child = child.nextSibling)
{
//alert(child);
target.appendChild(child.cloneNode(true));
}
};
Repaginator.prototype.loadNext = function(element)
{
if (this.prevIframe)
this.prevIframe.parentNode.removeChild(this.prevIframe);
if (!this.slideshow)
this.prevIframe = this.iframe;
if(element.ownerDocument.body.getAttribute('repagination') == 'isOn')
{
var doc = this.iframe.contentDocument;
this.pagecounter++;
if(this.slideshow)
{
element.ownerDocument.body.style.display = 'none';
var cloner = doc.body.cloneNode(true);
element.ownerDocument.documentElement.appendChild(cloner);
element.ownerDocument.body = cloner;
element.ownerDocument.body.setAttribute('repagination','isOn');
}
else
{
this.AppendChildren(doc.body, element.ownerDocument.body);
//element.ownerDocument.body.appendChild(doc.body.cloneNode(true));
}
var savedQuery;
if (this.attemptToIncrement)
{
savedQuery = this.query;
this.increment();
}
else if (this.numberToIncrement != null)
this.increment();
var xresult = doc
.evaluate(this.query,doc,null,0,null);
var node = this.getLast(xresult);
if (this.attemptToIncrement && (node == null || node.href == doc.location.href))
{
this.query = savedQuery;
this.numberToIncrement = null;
var xresult = doc
.evaluate(this.query,doc,null,0,null);
node = this.getLast(xresult);
}
this.attemptToIncrement = false;
if(node != null && (doc.location == null || node.href != doc.location.href))
{
if(doc.location != null)
{
this.prevPage =
doc.location.href;
}
if(
(
(this.nolimit == false)
&& (this.pagecounter <
this.pagelimit)
)
|| this.nolimit == true
)
{
var niframe = element.ownerDocument.createElement('iframe');
this.iframe = niframe;
niframe.style.display='none';
niframe.setAttribute('src',node.href);
repagination.RegisterRepaginator(this);
niframe.addEventListener('load',function()
{
var repaginator = repagination.GetRepaginator(this);
if(repaginator.slideshow)
{
myRepaginator = repaginator;
var timeout = setTimeout(repaginator.loadNextThunk, repaginator.seconds*1000);
}
else
{
repaginator.loadNext(this);
}
},true);
element.ownerDocument.body.appendChild(niframe);
}
else
{
element.ownerDocument.body.setAttribute('repagination','isOff');
}
}
else
{
element.ownerDocument.body.setAttribute('repagination','isOff');
}
}
};